<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<title>日历排班分类</title>
	<script type="text/javascript" src="../../js/boot.js"></script>
</head>

<body>
	<fieldset id="fd1" style="width: 97%; margin-bottom: 10px;">
		<legend><span>查询条件</span></legend>
		<div id="queryForm" class="fieldset-body">
			<table class="form-table" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td class="form-label">
						<span>班次名称：</span>
						<input name="sortName" class="mini-textbox" style="width: 150px" />
						<input name="sortName_link" value="like" class="mini-hidden" style="width: 150px" />
						<a style="margin: 0 0 0 0;" class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
					</td>
				</tr>
			</table>
		</div>
	</fieldset>

	<a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>
	<a class="mini-button" iconCls="icon-edit" onclick="edit()">编辑</a>
	<a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>

	</div>

	<div class="mini-fit">
		<div id="datagrid" class="mini-datagrid" style="width:100%;height:100%;" pageSize="20" idField="instID" allowResize="true">
			<div property="columns">
				<div type="indexcolumn"></div>
				<div field="sortID" visible="false"></div>
				<div field="sortName" headerAlign="center">班次名称"</div>
				<div field="startWorkTime" headerAlign="center">排班上班时间"</div>
				<div field="endWorkTime" headerAlign="center">排班下班时间</div>
				<div field="releaseTime" headerAlign="center">休息时长</div>
			</div>
		</div>
	</div>

	<div id="detailWin" class="mini-window" title="" style="width:500px;height:250px;" showMaxButton="true" showCollapseButton="true" showShadow="true"
		showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">
		<div id="detailForm" style="padding:10px;">
			<input class="mini-hidden" name="factorId">
			<table align="center">
				<tr>
					<td align="right">班次编号：</td>
					<td align="left"><input id="sortID" name="sortID" class="mini-textbox" enabled="false" required="true"></td>
					<td align="right">班次名称：</td>
					<td align="left"><input name="sortName" class="mini-textbox" required="true"></td>
				</tr>
				<tr>
					<td align="right">上班时间：</td>
					<td align="left">
						<input name="startWorkHour" class="mini-textbox" required="true" width="60">:
						<input name="startWorkMinute" class="mini-textbox" required="true" width="60">
					</td>
					<td align="right">下班时间：</td>
					<td align="left">
						<input name="endWorkHour" class="mini-textbox" required="true" width="60">:
						<input name="endWorkMinute" class="mini-textbox" required="true" width="60">
					</td>
				</tr>
				<tr>
					<td align="right">休息时长：</td>
					<td align="left"><input name="releaseTime" class="mini-textbox" /></td>
					<td align="right"></td>
					<td align="left"></td>
				</tr>
			</table>
		</div>
		<div property="footer" style="text-align:center;padding:5px;padding-right:15px;">
			<a class="mini-button" iconCls="icon-save" onClick="save()">保存</a>
			<a class="mini-button" iconCls="icon-cancel" onClick="cancel()">取消</a>
		</div>
	</div>
</body>

<script type="text/javascript">
	miniInit();

	var queryForm = new mini.Form("#queryForm");
	var form = new mini.Form("#detailForm");
	var win = mini.get("detailWin");

	var datagrid = mini.get("datagrid");
	datagrid.set({
		url: http.getUrl("/oa/calendar/sort/list.do")
	});
	datagrid.on("drawcell", function (e) {
		var record = e.record,
			column = e.column,
			field = e.field,
			value = e.value;
		var uid = record._uid;
		//action列，超连接操作按钮
		debugger
		if (e.column.field == "startWorkTime") {
			e.cellHtml = record.startWorkHour + ":" + record.startWorkMinute;
		} else if (e.column.field == "endWorkTime") {
			e.cellHtml = record.endWorkHour + ":" + record.endWorkMinute;
		}
	});

	// 表单与表格绑定数据
	var db = new mini.DataBinding();
	db.bindForm("detailForm", datagrid);

	search();

	function search() {
		var data = queryForm.getData(true, false);
		datagrid.load(data, null, miniui.showLoadErrorMessageBox);
	}

	// 新增
	function add() {
		datagrid.clearSelect(false);
		form.reset();
		win.setTitle("新增");
		win.showAtPos('center', 'middle');
	}

	// 修改
	function edit() {
		if (datagrid.getSelected()) {
			win.setTitle("修改");
			win.showAtPos('center', 'middle');
		} else {
			mini.alert("请选中需要修改的数据行", "提示", null);
		}
	}
	// 保存污染物
	function save() {
		if (!form.validate()) {
			return;
		}
		mini.mask({
			el: document.body,
			cls: 'mini-mask-loading',
			html: '数据保存中...'
		});
		var data = form.getData();
		http.post(http.getUrl("/oa/calendar/sort/save.do"), data, function (page) {
			mini.unmask();
			win.hide();
			mini.alert("保存成功", "提示", null);
			datagrid.reload();
		});
	}

	function cancel() {
		win.hide();
	}

	// 删除用户
	function remove() {
		if (datagrid.getSelected() == null) {
			mini.alert("请选中需要删除的数据行", "提示", null);
			return;
		}

		mini.confirm("确认删除该数据信息吗？", "删除操作", function (e) {
			if (e == "ok") {
				mini.mask({
					el: document.body,
					cls: 'mini-mask-loading',
					html: '数据删除中...'
				});
				var ids = datagrid.getSelected().sortID;
				var data = {
					"sortID": ids
				};
				http.post("/oa/calendar/sort/delete.do", data, function (page) {
					mini.unmask();
					win.hide();
					mini.alert("删除成功", "提示", null);
					datagrid.reload();
				});
			}
		});
	}
</script>

</html>